package com.rem.resources;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import org.springframework.core.io.Resource;

import java.io.IOException;

/**
 * @author Rem
 * @date 2023-03-07
 */
public class ResourceLoaderDemo {

    public static void main(String[] args) throws IOException {

       // ApplicationContext applicationContext = new ClassPathXmlApplicationContext();
        ApplicationContext applicationContext = new FileSystemXmlApplicationContext();
//        通过ApplicationContext访问资源
//        ApplicationContext实例获取Resource实例时，
//        默认采用与ApplicationContext相同的资源访问策略
        Resource resource = applicationContext.getResource("my1.txt");
        String filename = resource.getFilename();
        System.out.println(filename);
    }
}